import { ajax } from '@/utils'

import {
  GetBmUserRes,
  getScoreDetailRes,
  GetUserManageListRes
} from './userTypes'

export default {
  /** 用户管理列表 */
  getUserManageList(data): Promise<GetUserManageListRes> {
    return ajax.post('/yswy-zy-member-manage/memberManage/list', data)
  },
  /** 赠送积分 */
  giveStore(id: number, store: string, reason: string): Promise<void> {
    return ajax.post(
      `/yswy-zy-member-manage/memberManage/givePoint/${id}?point=${store}&reason=${reason}`
    )
  },
  /** 冻结账户 */
  frozeUser(id: number) {
    return ajax.put(`/yswy-zy-member-manage/memberManage/froze/${id}`)
  },
  /** 启用账户 */
  activeUser(id: number) {
    return ajax.put(`/yswy-zy-member-manage/memberManage/active/${id}`)
  },
  /** 积分明细 */
  getScoreDetail(data): Promise<getScoreDetailRes> {
    return ajax.post('/yswy-zy-member-manage/memberManage/pointDetail', data)
  },
  /** 关联的BM账号 */
  getBmUser(params): Promise<GetBmUserRes> {
    return ajax.get('/yswy-zy-member-manage/memberManage/bmUser', { params })
  },
  /** 注销用户 */
  getLogOffUser(id: any): Promise<GetBmUserRes> {
    return ajax.get(`/yswy-zy-member-manage/memberManage/cancel/${id}`)
  }
}
